<?php 
session_start();
include "../../../cfg/cfg.inc.php";
include "../../../include/functions.inc.php";
$idStuAsig = getParam("id");

$Fec = date('d-m-Y');
$mes = date('m');
$dia = date('d');
$ano = date('y');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Certificacion Cursos</title>
        <?php 
        function num2letras($num, $fem = true, $dec = true) { 
        //if (strlen($num) > 14) die("El n?mero introducido es demasiado grande"); 
           $matuni[2]  = "dos"; 
           $matuni[3]  = "tres"; 
           $matuni[4]  = "cuatro"; 
           $matuni[5]  = "cinco"; 
           $matuni[6]  = "seis"; 
           $matuni[7]  = "siete"; 
           $matuni[8]  = "ocho"; 
           $matuni[9]  = "nueve"; 
           $matuni[10] = "diez"; 
           $matuni[11] = "once"; 
           $matuni[12] = "doce"; 
           $matuni[13] = "trece"; 
           $matuni[14] = "catorce"; 
           $matuni[15] = "quince"; 
           $matuni[16] = "dieciseis"; 
           $matuni[17] = "diecisiete"; 
           $matuni[18] = "dieciocho"; 
           $matuni[19] = "diecinueve"; 
           $matuni[20] = "veinte"; 
           $matunisub[2] = "dos"; 
           $matunisub[3] = "tres"; 
           $matunisub[4] = "cuatro"; 
           $matunisub[5] = "quin"; 
           $matunisub[6] = "seis"; 
           $matunisub[7] = "sete"; 
           $matunisub[8] = "ocho"; 
           $matunisub[9] = "nove"; 

           $matdec[2] = "veint"; 
           $matdec[3] = "treinta"; 
           $matdec[4] = "cuarenta"; 
           $matdec[5] = "cincuenta"; 
           $matdec[6] = "sesenta"; 
           $matdec[7] = "setenta"; 
           $matdec[8] = "ochenta"; 
           $matdec[9] = "noventa"; 
           $matsub[3]  = 'mill'; 
           $matsub[5]  = 'bill'; 
           $matsub[7]  = 'mill'; 
           $matsub[9]  = 'trill'; 
           $matsub[11] = 'mill'; 
           $matsub[13] = 'bill'; 
           $matsub[15] = 'mill'; 
           $matmil[4]  = 'millones'; 
           $matmil[6]  = 'billones'; 
           $matmil[7]  = 'de billones'; 
           $matmil[8]  = 'millones de billones'; 
           $matmil[10] = 'trillones'; 
           $matmil[11] = 'de trillones'; 
           $matmil[12] = 'millones de trillones'; 
           $matmil[13] = 'de trillones'; 
           $matmil[14] = 'billones de trillones'; 
           $matmil[15] = 'de billones de trillones'; 
           $matmil[16] = 'millones de billones de trillones'; 

           $num = trim((string)@$num); 
           if ($num[0] == '-') { 
              $neg = 'menos '; 
              $num = substr($num, 1); 
           }else 
              $neg = ''; 
           while ($num[0] == '0') $num = substr($num, 1); 
           if ($num[0] < '1' or $num[0] > 9) $num = '0' . $num; 
           $zeros = true; 
           $punt = false; 
           $ent = ''; 
           $fra = ''; 
           for ($c = 0; $c < strlen($num); $c++) { 
              $n = $num[$c]; 
              if (! (strpos(".,'''", $n) === false)) { 
                 if ($punt) break; 
                 else{ 
                    $punt = true; 
                    continue; 
                 } 

              }elseif (! (strpos('0123456789', $n) === false)) { 
                 if ($punt) { 
                    if ($n != '0') $zeros = false; 
                    $fra .= $n; 
                 }else 

                    $ent .= $n; 
              }else 

                 break; 

           } 
           $ent = '     ' . $ent; 
           if ($dec and $fra and ! $zeros) { 
              $fin = ' coma'; 
              for ($n = 0; $n < strlen($fra); $n++) { 
                 if (($s = $fra[$n]) == '0') 
                    $fin .= ' cero'; 
                 elseif ($s == '1') 
                    $fin .= $fem ? ' una' : ' un'; 
                 else 
                    $fin .= ' ' . $matuni[$s]; 
              } 
           }else 
              $fin = ''; 
           if ((int)$ent === 0) return 'Cero ' . $fin; 
           $tex = ''; 
           $sub = 0; 
           $mils = 0; 
           $neutro = false; 
           while ( ($num = substr($ent, -3)) != '   ') { 
              $ent = substr($ent, 0, -3); 
              if (++$sub < 3 and $fem) { 
                 $matuni[1] = 'una'; 
                 $subcent = 'as'; 
              }else{ 
                 $matuni[1] = $neutro ? 'un' : 'uno'; 
                 $subcent = 'os'; 
              } 
              $t = ''; 
              $n2 = substr($num, 1); 
              if ($n2 == '00') { 
              }elseif ($n2 < 21) 
                 $t = ' ' . $matuni[(int)$n2]; 
              elseif ($n2 < 30) { 
                 $n3 = $num[2]; 
                 if ($n3 != 0) $t = 'i' . $matuni[$n3]; 
                 $n2 = $num[1]; 
                 $t = ' ' . $matdec[$n2] . $t; 
              }else{ 
                 $n3 = $num[2]; 
                 if ($n3 != 0) $t = ' y ' . $matuni[$n3]; 
                 $n2 = $num[1]; 
                 $t = ' ' . $matdec[$n2] . $t; 
              } 
              $n = $num[0]; 
              if ($n == 1) { 
                 $t = ' cien ' . $t; 
              }elseif ($n == 5){ 
                 $t = ' ' . $matunisub[$n] . 'ient' . $subcent . $t; 
              }elseif ($n != 0){ 
                 $t = ' ' . $matunisub[$n] . 'cien' . $subcent . $t; 
              } 
              if ($sub == 1) { 
              }elseif (! isset($matsub[$sub])) { 
                 if ($num == 1) { 
                    $t = ' mil'; 
                 }elseif ($num > 1){ 
                    $t .= ' mil'; 
                 } 
              }elseif ($num == 1) { 
                 $t .= ' ' . $matsub[$sub] . '?n'; 
              }elseif ($num > 1){ 
                 $t .= ' ' . $matsub[$sub] . 'ones'; 
              }   
              if ($num == '000') $mils ++; 
              elseif ($mils != 0) { 
                 if (isset($matmil[$sub])) $t .= ' ' . $matmil[$sub]; 
                 $mils = 0; 
              } 
              $neutro = true; 
              $tex = $t . $tex; 
           } 
           $tex = $neg . substr($tex, 1) . $fin; 
           return ucfirst($tex); 
        } 
        ?>
        <script type="text/javascript" src="../../../js/prototype.js">

        </script>
        <script>
        function onbeforeprint(){
        noprint.style.visibility = 'hidden';
        noprint.style.position = 'absolute';
        }
        function onafterprint(){
        noprint.style.visibility = 'visible';
        noprint.style.position = 'relative';
        }
        </script>

        <style type="text/css">
        <!--
        
        #header {
                height: 100px;
                width: 700px;
        }
        #header #no {
                height: 50px;
                width: 120px;
                float: right;
                margin-top: 30px;
        }
        #cursos {
                height: 400px;
                width: 700px;
                padding: 10px;
        }
        #footer {
                height: 150px;
                width: 700px;
        }
        #firma {
                height: 50px;
                width: 700px;
        }
        .letralittle {
                font-size: 12px;
        }
        #subhead {
                width: 700px;
                text-align: center;
        }
        #header #logo {
                height: 90px;
                width: 100px;
                float: left;
        }
        .centrado {
                text-align: center;
        }
        -->
        </style>
    </head>
    <body>
        <div id="wrapper">
            <div id="header">
                <div id="logo"><img src="logocinde.jpg" alt="logo" width="100" height="90" />  </div>
                <div id="no">
                    <form id="form1" name="form1" method="post" action="">
                        <input type="button" name="printer" id="printer" class="btn btn-info" value="Imprimir" onclick="$('no').hide();window.print();$('no').show();" />
                    </form>
                </div>
            </div>
            <div id="subhead">EL INFRANSCRITO DE LA OFICINA DE REGISTRO Y CONTROL ACADEMICO DEL CENTRO INTERNACIONAL DE DESARROLLO EMPRESARIAL<BR />
            CERTIFICA<br />
            QUE OBTUVO A LA VISTA DE LOS REGISTROS DE LAS EVALUACIONES FINALES DEL ESTUDIANTE:<br />
            <strong>
            <?PHP 
                $Querry_recordSetAlum = "SELECT cllg_student.ID,cllg_student.FIRST_NAME,cllg_student.SECOND_NAME,cllg_student.LAST_NAME,cllg_career.NAME,cllg_student_assign.FK_CYCLE 
                                        FROM cllg_student,cllg_career,cllg_student_assign 
                                        WHERE cllg_student_assign.ID = '$idStuAsig' 
                                        AND cllg_student_assign.FK_STUDENT = cllg_student.ID 
                                        AND cllg_student_assign.FK_CAREER = cllg_career.ID";
                
                $recordsetAlum = $db->query($Querry_recordSetAlum);
                $rowRecordsetAlum = mysql_fetch_assoc($recordsetAlum);
                echo $rowRecordsetAlum['FIRST_NAME'];?> <?PHP echo $rowRecordsetAlum['SECOND_NAME'];?> <?PHP echo $rowRecordsetAlum['LAST_NAME'];?></strong><br />
                <strong>CARNET:<?PHP echo $rowRecordsetAlum['ID'];?></strong>
                <br />
                <br />
                EN LOS CUALES CONSTA QUE APROBO LAS SIGUIENTES ASIGNATURAS DEL <BR />
                DIPLOMADO UNIVERSITARION EN: <br />
                <!--<strong><?PHP //echo $rowRecordsetAlum['NAME'];?>&nbsp;<?PHP //echo $rowRecordsetAlum['FK_CYCLE'];?></strong></div>-->
                <strong><?php echo $rowRecordsetAlum['NAME'];?></strong>
            </div>
            <br />
            <div id="cursos">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <th align="left">No.</th>
                        <th align="left">ASIGNATURA</th>
                        <th>Nota</th>
                        <th align="left">Calificacion Letras</th>
                    </tr>
                    <tr>
                        <td colspan="4"><hr /></td>
                    </tr>
                    <?PHP 
                        $Querry_recordSetCurso = "SELECT * 
                                                  FROM cllg_assign_detail,cllg_courses_catalog 
                                                  WHERE cllg_assign_detail.FK_ASSIGN = '$idStuAsig' 
                                                  AND cllg_assign_detail.FK_COURSE = cllg_courses_catalog.CODE 
                                                  AND cllg_assign_detail.APROVED = 1";
                        
                        $recordsetCurso = $db->query($Querry_recordSetCurso);
                        while ($rowRecordsetCurso = $db->fetch_assoc($recordsetCurso)){?>
                    <tr>
                        <td><?PHP echo $rowRecordsetCurso['CODE'];?></td>
                        <td><?PHP echo $rowRecordsetCurso['NAME'];?></td>
                        <td align="center"><?PHP echo number_format($rowRecordsetCurso['SCORE'],0);?></td>
                        <td><? 
                            $numero = $rowRecordsetCurso['SCORE'];
                            $buscar = '.';
                            $longitud = strlen ($numero);
                            $resultado = stristr($numero, $buscar);
                            $longitud2 = strlen ($resultado);
                            $despsPunto = substr($resultado, 1, 11);
                            $kk = $longitud-$longitud2;
                            $antesPunto = substr($numero, 0, $kk);
                            echo num2letras($antesPunto); 
                        ?>
                        </td>
                    </tr>
                    <?php }?>
                    <tr>
                        <td colspan="4" align="center">*****************ULTIMA LINEA*****************</td>
                    </tr>
                </table>
            </div>
            <div id="footer"><strong>OBSERVACION:</strong><br /><span class="letralittle">
                Este documento es una copia fiel de las calificaciones obtenidas por el(a) estudiante. Las clases son de ciclo cuatrimestral. Calificado <br /> 
                sobre cien puntos con un m&iacute;nimo de setenta puntos para aprobar el diplomado. Las firmas y sellos deben ser originales. <br />
                En esta certificaci&oacute;n no valen tachones, borrones, ni enmiendas.</span> <br />
            <span class="centrado">*****************ULTIMA LINEA***************** </span><br />
            <br /><br />
            Guatemala <?php echo $dia." del mes ".$mes." del a&ntilde;o "."20".$ano;?>
            <br /><Br />
            </div>
            <br /><Br />
            <div id="firma">
                <table width="34%" border="0" align="right" cellpadding="0" cellspacing="0">
                    <tr>
                        <td><hr /></td>
                    </tr>
                    <tr>
                        <td align="center">Ing. MBA Jorge Eduardo Prado</td>
                    </tr>
                    <tr>
                        <td align="center">Director General</td>
                    </tr>
                </table>
            </div>
        </div>
    </body>
</html>
